﻿using System;

namespace shiyan
{
    class Program
    {
        static void Main(string [] args)
        {
            //用来检验args是否为空的变量
            bool isNull = true;
            //文本字符串长度
            int len = 0;
            //输入文本信息
            string qrText = null;

            //检验命令行参数是否为空
            foreach (String str in args)
            {
                //若非空，则isNull为false
                if (str != null)
                {
                    isNull = false;
                }
            }

            //若命令行参数不为空，则根据命令行参数初始化文本信息变量
            if (isNull == false)
            {
                len = args[0].Length;
                qrText = args[0];
            }
            //若命令行参数为空，则提示重新输入并初始化文本信息变量
            else {
                Console.WriteLine("The text is null, please type in:");
                qrText = Console.ReadLine();
                len = qrText.Length;
            }

            //如果文本信息不符合长度要求，则重新输入
            while (len > 50)
            {
                Console.WriteLine("The text doesn't match the length, please type in again:");
                qrText = Console.ReadLine();
                len = qrText.Length;
            }

            Console.WriteLine();

            qrCode form = new qrCode(qrText);
            form.ShowDialog();
        }
    }
}
